﻿@model PagedList<View_MemberUpApply>
@{
    ViewBag.Title = "会员升级申请列表";
    Layout = "~/Views/Shared/_ContentLayout.cshtml";

    UpApplyQueryModel paramModel = new UpApplyQueryModel();
    if (ViewBag.paramModel != null)
    {
        paramModel = (UpApplyQueryModel)ViewBag.paramModel;
    }
    ADZ_MasterEntities dbcontext = new ADZ_MasterEntities();
    Dictionary<string, string> dc = new Dictionary<string, string>();
}

<form id="S_Form" class="form-inline definewidth m20" action="@Url.Action("memberupapplylist", "account")" method="get">
    <div class="form_query">
        <div>
            手机号：
            <input type="text" name="mobile" id="mobile" class="abc input-default" placeholder="" value="@paramModel.mobile">&nbsp;
        </div>
        <div>
            是否处理：
            <select id="is_do" name="is_do">
                <option value="-10" @(paramModel.is_do == -10 ? "selected" : "")>全部</option>
                @{
                    dc = new Dictionary<string, string>();
                    dc.Add("0", "未处理");
                    dc.Add("1", "已处理");
                    dc.Add("2", "已拒绝");
                }
                @HtmlPagerHelper.ShowSelectOpton(dc, paramModel.is_do.ToString());
            </select>&nbsp;
        </div>
        <div>
            申请时间：
            <input type="text" name="beg_time" class="calendar" id="beg_time" value="@paramModel.beg_time.ToString(2)"> - <input type="text" name="end_time" class="calendar" id="end_time" value="@paramModel.end_time.ToString(2)">&nbsp;
        </div>
        <div>
            @{Html.RenderPartial(Url.Content("~/Views/Common/PageSize.cshtml"), paramModel);}
        </div><div>
            <button type="submit" class="btn btn-primary">查询</button>&nbsp;&nbsp;
        </div>
    </div>
</form>

<table class="table table-bordered table-hover definewidth m10">
    <thead>
        <tr>
            <th>代购编号</th>
            <th>手机号</th>
            <th>会员名称</th>
            <th>联系姓名</th>
            <th>联系人手机</th>
            <th>申请时间</th>
            <th>处理结果</th>
            <th>处理时间</th>
            <th>备注</th>
            <th>操作</th>
        </tr>
    </thead>
    @if (Model != null && Model.Count != 0)
    {
        int index = 0;
        foreach (var m in Model)
        {
            index++;
    <tr class="@HtmlPagerHelper.TrClass(index)">
        <td>@m.replace_buyer_NO</td>
        <td>@m.account_mobile</td>
        <td>@m.member_name</td>
        <td>@m.contact_name</td>
        <td>@m.contact_telephone</td>
        <td>@m.create_time.ToString(1)</td>
        <td>
            @switch (m.is_do)
            {
                case 2:
                    @:<div class="red">已拒绝</div>
                    break;
                case 1:
                    @:<div class="green">已处理</div>
                    break;
                case 0:
                    @:<div>未处理</div>
                    break;
            }
        </td>
        <td>@m.do_time.ToString(1)</td>
        <td>@m.remark</td>
        <td>
            @switch (m.is_do)
            {
                case 0:
                    <a href="@Url.Action("UpLevel", "Account", new { uid = m.uid })">去处理升级</a>
                    <a href="javascript:void(0);" onclick="UpLevelRefuse(@m.seq_id,'@m.member_name')">审批拒绝</a>
                    break;
            }
        </td>
    </tr>
        }
    }
</table>
<div class="inline pull-left total">
    总行数：@ViewData["AllCount"]
</div>
<div class="inline pull-right page">
    @if (Model != null)
    {
        @Html.Pager(Model, HtmlPagerHelper.BasePagerOption)
    }
</div>
<script>
    var cancelButton =
        {
            text: '取消',
            elCls: 'button',
            handler: function () {
                this.close();
            }
        };
    reloadHandler = function () {
        window.location.reload();
    }
</script>


<style>
    #div_Mask {
        text-align: center;
        line-height: 100px;
        font-weight: bold
    }

    #J_Form {
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,.4);
        position: absolute;
        z-index: 1000;
        top: 0;
        left: 0;
        color: #000;
    }
</style>
<div id="div_Mask" class="hide">
    <form id="J_Form">
        <table class="table table-bordered definewidth m10 " style="width:800px;margin-top:200px;background-color:#fff">
            <tr>
                <th colspan="2">
                    确定要拒绝 <info class="red" id="refuse_username"></info> 申请吗？
                </th>
            </tr>
            <tr>
                <td class="tableleft">拒绝原因</td>
                <td><textarea id="remark" style="width:80%;" maxlength="2500" cols="4"></textarea></td>
            </tr>
            <tr>
                <td></td>
                <td>
                    <button type="button" class="btn btn-primary" id="btn_saveexp">提交</button> &nbsp;&nbsp;
                    <button type="button" class="btn btn-success" id="btn_cancel">取消</button>
                </td>
            </tr>
        </table>
    </form>
</div>
<script>
    var seq_id = 0;    
    function UpLevelRefuse(id,refusername) {
        seq_id = id;
        $("#refuse_username").text(refusername +"");
        $("#div_Mask").show();
    }
    $("#btn_cancel").click(function () {
        $("#div_Mask").hide();
    });
    $("#btn_saveexp").click(function () {
        var remark = $("#remark").val();
        if (remark == null || remark.length < 3) {
            BUI.Message.Alert("请输入拒绝原因", 'warning');
            return false;
        }

        BUI.Message.Show({
            title: '提示',
            msg: '确定要拒绝申请通过吗？',
            icon: 'question',
            buttons: [
                {
                    text: '确定',
                    elCls: 'button button-primary',
                    handler: function () {
                        url = "@Url.Action("UpLevelRefuse", "account")";
                        parameter = {
                            id: seq_id,
                            remark: $("#remark").val()
                        };
                        $.post(url, parameter, function (result) {
                            ShowActionResult(result, reloadHandler);
                            $("#div_Mask").hide();
                        });
                        this.close();
                    }
                },
                cancelButton
            ]
        });
    });

</script>